package demo;

import com.alibaba.xxpt.gateway.shared.client.http.ExecutableClient;
import com.alibaba.xxpt.gateway.shared.client.http.GetClient;
import org.junit.jupiter.api.Test;

/**
 * @Author: zjq
 * @Date: 2024/12/4 15:13
 */

public class dingtest {

    private static final String ACCESS_KEYTEST = "jshx-6GO6771imqe6tiz7FlUaQV7fy";
    private static final String SECRET_KEYTEST = "Mo8Z0uYKaK8q7atpRQUgDdSM010k8W504sP4XnAI";

    @Test
    public static void main(String[] args) {
        ExecutableClient executableClient =ExecutableClient.getInstance();
        executableClient.setAccessKey(ACCESS_KEYTEST);
        executableClient.setSecretKey(SECRET_KEYTEST);
        executableClient.setDomainName("open.on-premises.dingtalk.com");
        executableClient.setProtocal("https");
        executableClient.init();
//executableClient要单例，并且使用前要初始化，只需要初始化一次

        String api = "/gettoken.json";
        GetClient getClient = executableClient.newGetClient(api);
//设置参数
        getClient.addParameter("appkey", ACCESS_KEYTEST);
        getClient.addParameter("appsecret", SECRET_KEYTEST);
//调用API
        String apiResult = getClient.get();
        System.out.println(apiResult);



    }
}
